package com.itsm.xkitsm.liferoot.life.weather;

import org.json.JSONArray;
import org.json.JSONObject;

import android.content.Context;
import android.util.Log;


import java.util.List;


public class JsonParse {
	Context context;

	public JsonParse(Context context) {
		super();
		this.context = context;
	}

	// Ҫ��ʵ��������Ϣ
	private StringBuffer weatherInfo1;
	private StringBuffer weatherInfo2;
	private StringBuffer weatherInfo3;
	private StringBuffer weatherInfo4;
	private StringBuffer weatherInfo5;
	private StringBuffer weatherInfo6;

	// ͼƬ��Դ14,25,36
	private String weatherPicUrl1;
	private String weatherPicUrl2;
	private String weatherPicUrl3;
	private String weatherPicUrl4;
	private String weatherPicUrl5;
	private String weatherPicUrl6;

	private String weatherPicUrl7;
	private String weatherPicUrl8;
	private String weatherPicUrl9;
	private String weatherPicUr20;
	private String weatherPicUr21;
	private String weatherPicUr22;

	public Info_weather parseJson(String jsonData) {
		Info_weather info = new Info_weather();
		try {

			JSONObject allWeatherData = new JSONObject(jsonData);
			JSONObject weatherData = allWeatherData
					.getJSONObject("data");
			JSONArray forecast = weatherData.getJSONArray("forecast");
			JSONObject today = forecast.getJSONObject(0);
			JSONObject tomorrow = forecast.getJSONObject(1);
			JSONObject hday = forecast.getJSONObject(2);

			info.setCity(allWeatherData.getString("city"));
			info.setOne_date(today.getString("date"));
			info.setOne_weather(today.getString("type"));
			info.setOne_temp(today.getString("low")+"～"+today.getString("high"));
//			info.setOne_img_state1(weatherData.getString("img1"));
//			info.setOne_img_state2(weatherData.getString("img2"));
			info.setOne_win(today.getString("fx")+today.getString("fl"));


			info.setTwo_date(tomorrow.getString("date"));
			info.setTwo_weather(tomorrow.getString("type"));
			info.setTwo_temp(tomorrow.getString("low")+"～"+tomorrow.getString("high"));
//			info.setTwo_img_state1(weatherData.getString("img3"));
//			info.setTwo_img_state2(weatherData.getString("img4"));
			info.setTwo_win(tomorrow.getString("fx")+tomorrow.getString("fl"));


			info.setThree_date(hday.getString("date"));
			info.setThree_weather(hday.getString("type"));
			info.setThree_temp(hday.getString("low")+"～"+hday.getString("high"));
//			info.setThree_img_state1(weatherData.getString("img5"));
//			info.setThree_img_state2(weatherData.getString("img6"));
			info.setThree_win(hday.getString("fx")+hday.getString("fl"));


			info.setFour_date(weatherData.getString("date_y"));
			info.setFour_weather(weatherData.getString("weather4"));
			info.setFour_temp(weatherData.getString("temp4"));
			info.setFour_img_state1(weatherData.getString("img7"));
			info.setFour_img_state2(weatherData.getString("img8"));
			info.setFour_win(weatherData.getString("wind4"));


		} catch (Exception e) {
			e.printStackTrace();
		}
		return info;
	}


}
